package com.starhub.api.docarchive.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.starhub.api.docarchive.entity.DocArchiveBase;
import com.starhub.api.docarchive.entity.DocArchiveFollow;

import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

/**   
 * 知识库关注关系DAO层
 * @version: V1.0
 * @author: liuhf
 * @time 2025-05-18
 */
@Mapper
public interface DocArchiveFollowMapper extends BaseMapper<DocArchiveFollow> {
    
    @Select("SELECT a.* FROM doc_archive_base a " +
            "INNER JOIN doc_archive_follow f ON a.id = f.archive_id " +
            "WHERE f.user_id = #{userId} " +
            "AND f.delete_type = 0 " +
            "AND a.delete_type = 0 " +
            "ORDER BY f.create_time DESC")
    Page<DocArchiveBase> selectFollowedArchives(Page<DocArchiveBase> page, @Param("userId") Long userId);
} 